<%-- 
    Document   : Admin
    Created on : Dec 18, 2014, 3:09:49 PM
    Author     : Tran Thuy Duong
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
	<title>Handmade</title>
	<link rel="stylesheet" href="css_admin/style.css" type="text/css" media="all" />
        <script>
            function loadShowPro(){
                window.location="C_Pro_Admin?ProAction_ad=Show";
            }
            function confirmDelete(){
            
                var x = confirm("Bạn chắc chắn muốn xóa toàn bộ sản phẩm?");
                if(x==true)
                {
                    var xmlhttp;
                    if (window.XMLHttpRequest)
                      {// code for IE7+, Firefox, Chrome, Opera, Safari
                      xmlhttp=new XMLHttpRequest();
                      }
                    else
                      {// code for IE6, IE5
                      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                      }
                    xmlhttp.onreadystatechange=function()
                      {
                      if (xmlhttp.readyState==4 && xmlhttp.status==200)
                        {
                        document.getElementById("table").innerHTML=xmlhttp.responseText;
                        }
                      }
                    xmlhttp.open("GET","C_Pro_Admin?ProAction_ad=DeleteAll",true);
                    xmlhttp.send();
                }
                
            }
            
             function confirmDelPro(){
            
                var x = confirm("Bạn chắc chắn muốn xóa sản phẩm này?");
                if(x==true)
                {
                    
                    var masp = document.getElementById("masanpham").value;
                  
                    window.location = "C_Pro_Admin?ProAction_ad=delete_pro&masp=" + masp;
                }
                
            }
            
            
            function loadSearchPro(){
            
               
                    var xmlhttp;
                    if (window.XMLHttpRequest)
                      {// code for IE7+, Firefox, Chrome, Opera, Safari
                      xmlhttp=new XMLHttpRequest();
                      }
                    else
                      {// code for IE6, IE5
                      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                      }
                    xmlhttp.onreadystatechange=function()
                      {
                      if (xmlhttp.readyState==4 && xmlhttp.status==200)
                        {
                        document.getElementById("table").innerHTML=xmlhttp.responseText;
                        }
                      }
                      
                    var x = document.getElementById("field small-field").value;
                    var y = document.getElementById("field size3").value;
                    //alert(x + y);
                    
                    xmlhttp.open("GET","C_Pro_Admin?ProAction_ad=Search&txtSearch=" + x + "&timtheo=" + y,true);
                    xmlhttp.send();
                
                
            }
            
            function sort(){
            
                    var kieusap = document.getElementById("kieusap").value;
                    window.location = "C_Pro_Admin?ProAction_ad=Sort&kieusap=" + kieusap;
            
            }
            
            
        </script>
</head>
<body >
<!-- Header -->
<div id="header">
	<div class="shell">
		<!-- Logo + Top Nav -->
		<div id="top">
			<h1><a href="#">Handmade</a></h1>
			<div id="top-navigation">
				Xin chào <a href="#"><strong>Quản trị viên</strong></a>
				<span>|</span>
				<a href="#">Help</a>
				<span>|</span>
				<a href="#">Profile Settings</a>
				<span>|</span>
				<a href="#">Log out</a>
			</div>
		</div>
		<!-- End Logo + Top Nav -->
		
		<!-- Main Nav -->
		<div id="navigation">
			<ul>
			  <li><a href="C_Show_Customer" ><span>Khách hàng</span></a></li>
			    <li><a href="News.jsp"><span>Tin tức</span></a></li>
			    <li><a href="#"><span>Đơn hàng</span></a></li>
			    <li><a href="C_Show_Contact?ContactAction=Admin" ><span>Thông tin liên hệ</span></a></li>
			    <li><a href="#" class="active"><span>Sản phẩm</span></a></li>
			    <li><a href="#"><span>Services Control</span></a></li>
			</ul>
		</div>
		<!-- End Main Nav -->
	</div>
</div>
<!-- End Header -->

<!-- Container -->
<div id="container">
	<div class="shell">
		
		<!-- Small Nav -->
		<div class="small-nav">
			<a href="#">Khách hàng</a>
			<span>&gt;</span>
			Current Articles
		</div>
		<!-- End Small Nav -->
		
		
		
		
		<br />
		<!-- Main -->
		<div id="main">
			<div class="cl">&nbsp;</div>
			
			<!-- Content -->
			<div id="content">
				
				<!-- Box -->
				<div class="box">
					<!-- Box Head -->
					<div class="box-head">
						<h2 class="left">Sản phẩm</h2>
						<div class="right">
							<label>Tìm sản phẩm</label>
							<input type="text" class="field small-field"  id="field small-field" onkeyup="loadSearchPro()"/>
                                                        <label>&nbsp; &nbsp;Tìm theo &nbsp; &nbsp;</label>
							
                                                         <select class="field size3" id="field size3" name="timtheo">
                                                                <option value="tensp">Tên sản phẩm</option>
                                                                <option value="nhacc">Nhà cung cấp</option>
                                                                <option value="dmsp">Danh mục sản phẩm</option>
                                                                <option value="mota">Mô tả</option>
                                                                <option value="trangthai">Trạng thái</option>
                                                        </select>
						</div>
					</div>
					<!-- End Box Head -->	

					<!-- Table -->
					<div class="table" id="table">
                                             <c:set var="INFO" value="${requestScope.INFOPro_Show}"/>
                                             <c:if test="${not empty INFO}">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<tr>
                                                          
                                                                <th>STT</th>
								<th>Tên sản phẩm</th>
								<th>Nhà cung cấp</th>
                                                                <th>Mã DMSP</th>
								<th>Giá vốn</th>
								<th>Giá bán</th>
								<th>Khuyến mãi</th>
                                                                <th>Trạng thái</th>
                                                                
								<th width="110" class="ac">Content Control</th>
							</tr>
                                                    <c:set var="count" value="0"/>
                                                    <c:forEach var="rows" items="${INFO}">
                                                    <c:set var="count" value="${count + 1}"/>
                                                    
                                                    
                                                        <tr>
                                                            
                                                               
                                                                <td>${count}</td>
                                                                <td><a href="#">${rows.tensp}</a></td>
								<td>${rows.nhacc}</td>
                                                                <td>${rows.madmsp}</td>
								<td>${rows.giavon}</td>
								<td>${rows.giaban}</td>
								<td>${rows.khuyenmai}</td>
                                                                <td>${rows.trangthai}</td>
                                                                <input type="hidden" name="masp" value="${rows.masp}" id="masanpham"/>
                                                               
                                                                <c:url var="edit" value="Production_Update.jsp">
                                                                    <c:param name="masp" value="${rows.masp}"/>
                                                                    <c:param name="tensp" value="${rows.tensp}"/>
                                                                    <c:param name="nhacc" value="${rows.nhacc}"/>
                                                                    <c:param name="madmsp" value="${rows.madmsp}"/>
                                                                    <c:param name="mota" value="${rows.mota}"/>
                                                                    <c:param name="giavon" value="${rows.giavon}"/>
                                                                    <c:param name="giaban" value="${rows.giaban}"/>
                                                                    <c:param name="khuyenmai" value="${rows.khuyenmai}"/>
                                                                    <c:param name="trangthai" value="${rows.trangthai}"/>
                                                                    <c:param name="hinhanh" value="${rows.hinhanh}"/>
                                                                </c:url>
                                                               
								<td><a onclick="confirmDelPro()" class="ico del">Delete</a><a href="${edit}" class="ico edit">Edit</a></td>
							</tr>
                                                    </c:forEach>
							
						</table>
                                                </c:if>
						
						
						<!-- Pagging -->
						<div class="pagging">
							<div class="left">Showing 1-8 of 44</div>
							<div class="right">
								<a href="#">Previous</a>
								<a href="#">1</a>
								<a href="#">2</a>
								<a href="#">3</a>
								<a href="#">4</a>
								<a href="#">245</a>
								<span>...</span>
								<a href="#">Next</a>
								<a href="#">View all</a>
							</div>
						</div>
						<!-- End Pagging -->
						
					</div>
					<!-- Table -->
					
				</div>
				<!-- End Box -->
				
				<!-- Box -->
				<div class="box">
					<!-- Box Head -->
					<div class="box-head">
						<h2>Thêm sản phẩm</h2>
					</div>
					<!-- End Box Head -->
					
					<form action="C_Pro_Admin" method="get">
						
						<!-- Form -->
						<div class="form">
								<p>
									<span class="req">max 100 symbols</span>
									<label>Tên sản phẩm<span>*</span></label>
									<input type="text" class="field size1" name="tensp"/>
                                                                       
								</p>	
								<p class="inline-field">
									<label>Tên danh mục sản phẩm</label>
									<select class="field size3" name="madmsp" >
										<option value="HMLD">Handmade làm đẹp</option>
										<option value="BHM">Bếp Handmade</option>
                                                                                <option value="QTHM">Quà tặng Handmade</option>
									</select>
									
								</p>
								
								<p>
									<span class="req">max 100 symbols</span>
									<label>Nhà cung cấp<span>*</span></label>
									<input type="text" class="field size1" name="nhacc"/>
								</p>
								
								<p>
									<span class="req">max 100 symbols</span>
									<label>Mô tả<span>*</span></label>
									<input type="text" class="field size1" name="mota"/>
								</p>

								<p>
									<span class="req">max 100 symbols</span>
									<label>Giá vốn<span>*</span></label>
									<input type="number" class="field size1" name="giavon"/>
								</p>	
                                                                <p>
									<span class="req">max 100 symbols</span>
									<label>Giá bán<span>*</span></label>
									<input type="number" class="field size1" name="giaban" />
								</p>
                                                                <p>
									<span class="req">max 100 symbols</span>
									<label>Khuyến mãi<span>*</span></label>
                                                                        <input type="number" class="field size1" name="khuyenmai"/>
								</p>
                                                                <p class="inline-field">
									<label>Trạng thái</label>
									<select class="field size3" name="trangthai">
										<option value="Con">Còn hàng</option>
										<option value="Het">Hết hàng</option>
                                                                                
									</select>
									
								</p>
                                                                <p>
									<label>Hình ảnh<span>*</span></label>
									<input type="file" name="hinhanh"/>
								</p>
							
						</div>
						<!-- End Form -->
						
						<!-- Form Buttons -->
						<div class="buttons">
                                                    <input type="reset" class="button" value="Reset" />
							<input type="submit" class="button" value="Insert" name="ProAction_ad" />
						</div>
						<!-- End Form Buttons -->
					</form>
				</div>
				<!-- End Box -->

			</div>
			<!-- End Content -->
			
			<!-- Sidebar -->
			<div id="sidebar">
				
				<!-- Box -->
				<div class="box">
					
					<!-- Box Head -->
					<div class="box-head">
						<h2>Management</h2>
					</div>
					<!-- End Box Head-->
					
					<div class="box-content">
						
						
						
                                                <p><a onclick="confirmDelete()">Delete Selected</a></p><p id="result_delete"></p>
						
						<!-- Sort -->
						<div class="sort">
                                                    <a onclick="sort()" >Sắp theo khuyến mãi</a>
							
							<select class="field size3" name="kieusap" id="kieusap">
								<option value="tang">Tăng dần</option>
                                                                <option value="giam">Giảm dần</option>
							</select>
							
						</div>
						<!-- End Sort -->
						
					</div>
				</div>
				<!-- End Box -->
			</div>
			<!-- End Sidebar -->
			
			<div class="cl">&nbsp;</div>			
		</div>
		<!-- Main -->
	</div>
</div>
<!-- End Container -->

<!-- Footer -->
<div id="footer">
	<div class="shell">
		<span class="left">&copy; 2010 - CompanyName</span>
		<span class="right">
			Design by <a href="http://chocotemplates.com" target="_blank" title="The Sweetest CSS Templates WorldWide">Chocotemplates.com</a>
		</span>
	</div>
</div>
<!-- End Footer -->
	
</body>
</html>
